home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / Macintosh Tracker 1.20 / source / Server⁄Tracker 4.0 / setup_audio.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-01  |  2.5 KB  |  129 lines  |  [TEXT/KAHL]

  1. /* setup_audio.c */
  2. /* higher level interface to the raw metal */
  3.  
  4. /* $Id: setup_audio.c,v 4.0 1994/01/11 17:55:28 espie Exp espie $
  5.  * $Log: setup_audio.c,v $
  6.  * Revision 4.0  1994/01/11  17:55:28  espie
  7.  * Use autoinit.
  8.  *
  9.  * Revision 1.7  1994/01/09  17:36:22  Espie
  10.  * Generalized open.c.
  11.  *
  12.  * Revision 1.6  1994/01/08  02:04:21  Espie
  13.  * Suppressed multiple at_end.
  14.  *
  15.  * Revision 1.5  1994/01/06  22:32:42  Espie
  16.  * Use new pref scheme.
  17.  *
  18.  * Revision 1.4  1994/01/05  14:54:09  Espie
  19.  * *** empty log message ***
  20.  *
  21.  * Revision 1.3  1993/12/27  00:45:26  Espie
  22.  * Working.
  23.  *
  24.  * Revision 1.2  1993/12/26  18:54:21  Espie
  25.  * Modified in a more consistent way.
  26.  *
  27.  * Revision 1.1  1993/12/26  00:55:53  Espie
  28.  * Initial revision
  29.  *
  30.  * Revision 3.6  1993/12/04  16:12:50  espie
  31.  * BOOL -> boolean.
  32.  *
  33.  * Revision 3.5  1993/11/17  15:31:16  espie
  34.  * New high-level functions.
  35.  *
  36.  * Revision 3.4  1992/11/27  10:29:00  espie
  37.  * General cleanup
  38.  *
  39.  * Revision 3.3  1992/11/24  10:51:19  espie
  40.  * Added check before closing for the sgi.
  41.  *
  42.  * Revision 3.1  1992/11/20  14:53:32  espie
  43.  * Added finetune.
  44.  *
  45.  * Revision 3.0  1992/11/18  16:08:05  espie
  46.  * New release.
  47.  *
  48.  */
  49.  
  50.  
  51. #include <stdio.h>
  52. #include <stdlib.h>
  53. #include <string.h>
  54.  
  55. #include "defs.h"
  56. #include "extern.h"
  57. #include "tags.h"
  58. #include "prefs.h"
  59.  
  60. ID("$Id: setup_audio.c,v 4.0 1994/01/11 17:55:28 espie Exp espie $")
  61.  
  62. LOCAL void init_audio P((void));
  63.  
  64. LOCAL void (*INIT)P((void)) = init_audio;
  65.  
  66. LOCAL boolean opened = FALSE;
  67. LOCAL int ask_freq, real_freq, oversample;
  68. LOCAL boolean stereo;
  69.  
  70.  
  71. LOCAL void init_audio()
  72.    {
  73.    at_end(do_close_audio);
  74.    }
  75.  
  76. /* setup_audio(frequency, stereo, oversample):
  77.  * try to avoid calling open_audio and other things
  78.  * all the time
  79.  */
  80. void setup_audio(f, s, o)
  81. int f;
  82. boolean s;
  83. int o;
  84.    {
  85.    INIT_ONCE;
  86.  
  87.    if (!opened)
  88.       {
  89.       ask_freq = f;
  90.       stereo = s;
  91.       oversample = o;
  92.       real_freq = open_audio(f, s);
  93.       init_player(o, real_freq);
  94.       opened = TRUE;
  95.       }
  96.    else
  97.       {
  98.       int new_freq;
  99.  
  100.       if (s != stereo || f != ask_freq)
  101.          {
  102.          ask_freq = f;
  103.          stereo = s;
  104.          close_audio();
  105.          new_freq = open_audio(f, s);
  106.          }
  107.       else
  108.          new_freq = real_freq;
  109.  
  110.       if (new_freq != real_freq || oversample != o)
  111.          {
  112.          real_freq = new_freq;
  113.          oversample = o;
  114.          init_player(o, real_freq);
  115.          }
  116.       }
  117.    set_synchro(get_pref_scalar(PREF_SYNC));
  118.    }
  119.  
  120. void do_close_audio()
  121.    {
  122.    if (opened)
  123.       {
  124.       close_audio();
  125.       }
  126.    opened = FALSE;
  127.    }
  128.  
  129.